package ezonsport.android.ui.stepSystem.dataHistory;

import java.util.List;
import java.util.Map;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.ViewSwitcher;
import ezonsport.android.R;
import ezonsport.android.application.SystemConstant;

public class StepAdapter extends BaseAdapter {
	private Context mContext;
	private List<Map<String, Object>> mListItems;
	private LayoutInflater mListContainer;  
	
	ViewSwitcher footerView;
	
	public final class ListItemView{
		public TextView mTextDate;
		public ImageView mImageShare;
		public TextView mTextMile;
		public TextView mTextStep;
		public TextView mTextCalory;
	}
	public StepAdapter(Context context, List<Map<String, Object>> listItems){
		mContext = context;
		mListContainer = LayoutInflater.from(context);
		mListItems = listItems;
		footerView = (ViewSwitcher)mListContainer.inflate(R.layout.footer, null);
		
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mListItems.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ListItemView listItemView = null;
		if(convertView == null){
			listItemView = new ListItemView();
			convertView = mListContainer.inflate(R.layout.list_item, null);
			listItemView.mTextDate = (TextView)convertView.findViewById(R.id.listitem_tx_date);
			listItemView.mImageShare = (ImageView)convertView.findViewById(R.id.listitem_image_share);
			listItemView.mTextMile = (TextView)convertView.findViewById(R.id.listitem_tx_miles);
			listItemView.mTextStep = (TextView)convertView.findViewById(R.id.listitem_tx_steps);
			listItemView.mTextCalory = (TextView)convertView.findViewById(R.id.listitem_tx_calories);
			convertView.setTag(listItemView);
		}else{
			listItemView = (ListItemView)convertView.getTag();
		}
		listItemView.mTextDate.setText((String)mListItems.get(position).get(SystemConstant.DataHistory.LISTITEM_DATE));
		listItemView.mTextMile.setText((String)mListItems.get(position).get(SystemConstant.DataHistory.LISTITEM_MILES));
		listItemView.mTextStep.setText((String)mListItems.get(position).get(SystemConstant.DataHistory.LISTITEM_STEPS));
		listItemView.mTextCalory.setText((String)mListItems.get(position).get(SystemConstant.DataHistory.LISTITEM_CALORIES));
		return convertView;
	}
	
	

}
